﻿using System;

namespace QuickUIT
{
    /// <summary>
    /// A simple timer for tracking timeouts.
    /// </summary>
    public class AutomationTimer
    {
        private readonly long _timeout;
        private long _ticks; 

        /// <summary>
        /// Initializes a new timer. 
        /// </summary>
        /// <param name="timeout">The timer timeout value in milliseconds.</param>
        public AutomationTimer(long timeout)
        {
            _timeout = timeout; 
        }

        /// <summary>
        /// Starts the timer.
        /// </summary>
        public void Start()
        {
            _ticks = DateTime.Now.Ticks; 
        }

        /// <summary>
        /// Determines if the timer has exceeded its timeout value. 
        /// </summary>
        /// <returns>True if the timer has exceeded its timeout false; otherwise false.</returns>
        public bool HasTimedOut()
        {
            return DateTime.Now.Ticks - _ticks > _timeout * 10000; 
        }
    }
}
